package com.ba.base.utils

object ImageUrlDecode {

    fun decode(url: String): IntArray {
        if (url.trim() == "") {
            return intArrayOf(-1, -1)
        }
        val wIndex = url.lastIndexOf("w=")
        val hIndex = url.lastIndexOf("&h=")
        var with = -1
        var height = -1
        if (wIndex in 1 until hIndex) {
            with = try {
                url.subSequence(wIndex + 2, hIndex) as Int
            } catch (e: Exception) {
                -1
            }
            height = try {
                url.subSequence(hIndex + 3, url.length) as Int
            } catch (e: Exception) {
                -1
            }
        }
        return intArrayOf(with, height)
    }
}

fun main() {


}